package com.netty.bfport.http.config.Thread;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.netty.bfport.netty.server.NettyServerHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: zhaoyang05
 * @Data: 2022/4/9 16:54
 * @Description
 */
@Slf4j
public class WebMessagePushThread implements Runnable {
    private String cron = "";

    public WebMessagePushThread(String cron) {
        this.cron = cron;
    }

    @Override
    public void run() {
        NettyServerHandler.channelsWeb.writeAndFlush(JSON.toJSONString(NettyServerHandler.message, SerializerFeature.WriteMapNullValue));
        NettyServerHandler.channelsWeb.writeAndFlush(new TextWebSocketFrame(JSON.toJSONString(NettyServerHandler.message, SerializerFeature.WriteMapNullValue)));
        log.info("推送数据 {}", NettyServerHandler.message);
        System.out.println(cron);

    }
}
